#异常捕获语法：try except

#捕获单种异常
try:
    1 / 0
except ZeroDivisionError as e:#---------as后面的对象就是错误信息
    print("出现异常了")

#捕获多种异常
try:
    1 / 0
    # print(name)
except (ZeroDivisionError, NameError) as e:
    print("出现异常了")

#捕获所有异常

try:
    1/0
except Exception as e:
    print(f"Error, 异常信息是{e}")

#except表示出现异常该咋办，else语句表示没有出现异常又该咋办

name = "feng"
try :
    print(name)
except:
    print("Error")
else:
    print("It's ok")

#finally表示无论如何也要做的工作，一般放在else或者except后面,通常写close()
name = "feng"
try :
    print(name)
except:
    print("Error")
else:
    print("It's ok")
finally:
    print("Hello, Mr.Feng")


#-----------------模块-------------------
#import带上模块的所有功能
import time
print("Hello")
# time.sleep(2)
print("Nice to meet you")

#from 模块名 import 功能名---------带上一个模块的一个功能名

from time import sleep
print("Nice to meet you")
# sleep(2)
print("Nice to meet you too")

#----------as加别名
import time as t
print("Hello")
# t.sleep(2)
print("Nice to meet you")

print("-----------------------------------------------------------")

# import my_mod as mm
# result = mm.my_func(3,4)
# print(f"导包模块：{result}")

# import my_mod as mm
from my_mod import * 
print(f"8 + 7得到{test_a(8, 7)}")
# print(f"8 - 7得到{test_b(8, 7)}")


print("-----------------------------------------------------------")
#-------模块就是一个python文件，而包就相当于一个文件夹，用来保存python文件的集合
